package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.PayRegist;
import com.sl.au.entity.ReceivedPaymentDetailInfoView;
import com.sl.au.repository.ReceivedPaymentDetailInfoViewRepository;
import com.sl.au.service.ReceivedPaymentDetailInfoViewService;

@Service("ReceivedPaymentDetailInfoViewService")
@Transactional
public class ReceivedPaymentDetailInfoViewServiceImpl extends BaseServiceImpl implements ReceivedPaymentDetailInfoViewService {

	@Autowired
	ReceivedPaymentDetailInfoViewRepository receivedPaymentDetailInfoViewRepository;
	@Override
	public ReceivedPaymentDetailInfoViewRepository getRepository() {
		// TODO Auto-generated method stub
		return this.receivedPaymentDetailInfoViewRepository;
	}
	@Override
	public List<ReceivedPaymentDetailInfoView> getPayAllHistory(int start, int length, String contractId,
			String contractType, String object, String object2) {
		Page<ReceivedPaymentDetailInfoView> payRegists=null;
		Pageable pageable=new PageRequest(start/length,length, Sort.Direction.DESC,"createTime");
		payRegists=receivedPaymentDetailInfoViewRepository.findBySContractIdAndSContractType(contractId,contractType,pageable);
		return payRegists.getContent();
	}
	@Override
	public Long getPayAllRegistCount(String contractId) {
		Long count=receivedPaymentDetailInfoViewRepository.getPayRegistCount(contractId);
		return count;
	}
	@Override
	public List<ReceivedPaymentDetailInfoView> getPayHistory(int start, int length, String contractId,
			String contractType, String userId, String object, String object2) {
		Page<ReceivedPaymentDetailInfoView> payRegists=null;
		Pageable pageable=new PageRequest(start/length,length, Sort.Direction.DESC,"createTime");
		payRegists=receivedPaymentDetailInfoViewRepository.findBySContractIdAndSContractTypeAndSCreateUserId(contractId,contractType,userId,pageable);
		return payRegists.getContent();
	}
	@Override
	public Long getPayRegistCount(String contractId, String userId) {
		Long count=receivedPaymentDetailInfoViewRepository.getPayRegistCount(contractId,userId);
		return count;
	}

}
